﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Pay.Core;
using Pay.Services;

namespace Pay.Controllers
{
    /// <summary>
    /// 支付通知回调
    /// </summary>
    public class NotifyController : Controller
    {
        private readonly IPayService _payService;

        /// <summary>
        /// ctor
        /// </summary>
        public NotifyController(IPayService payService)
        {
            _payService = payService;
        }

        /// <summary>
        /// 支付宝扫码回调
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AliQRCodeAsync()
        {
            return await _payService.AliNotifyAsync(DTO.PaySourceEnum.QRCode, Request);
        }

        /// <summary>
        /// 支付宝APP回调
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AliAppAsync()
        {
            return await _payService.AliNotifyAsync(DTO.PaySourceEnum.App, Request);
        }

        /// <summary>
        /// 支付宝PC端网页回调
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AliPcWebAsync()
        {
            return await _payService.AliNotifyAsync(DTO.PaySourceEnum.PCWeb, Request);
        }

        /// <summary>
        /// 支付宝移动端网页回调
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AliMobileWebAsync()
        {
            return await _payService.AliNotifyAsync(DTO.PaySourceEnum.MobileWeb, Request);
        }
    }
}
